﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>欢迎登录后台管理系统</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="js/jquery.js"></script>
<script src="js/cloud.js" type="text/javascript"></script>
    <script src="./jquery/jquery3.1.1.js"></script>
<!-- 引入bootstrap，需要两个，分别是：css，js（js引入的时候先引入jquery） -->
<script src="./bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
<script language="javascript">
	$(function(){
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
	$(window).resize(function(){  
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
    })  
});  
</script> 

</head>

<body style="background-color:#1c77ac; background-image:url(images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">



    <div id="mainBody">
      <div id="cloud1" class="cloud"></div>
      <div id="cloud2" class="cloud"></div>
    </div>  


<div class="logintop">    
    <span>欢迎登录后台管理界面平台</span>    
<!--    <ul>-->
<!--    <li><a href="#">回首页</a></li>-->
<!--    <li><a href="#">帮助</a></li>-->
<!--    <li><a href="#">关于</a></li>-->
<!--    </ul>    -->
    </div>
    
    <div class="loginbody">
    
    <span class="systemlogo"></span> 
       
    <div class="loginbox">
    
    <ul>
    <li><input name="" type="text" class="loginuser" id="loginAccount" value="" onclick="JavaScript:this.value=''"/></li>
    <li>
        <input name="" type="password" class="loginpwd" id="loginPassword" value="" onclick="JavaScript:this.value=''"/>
        <span id="tip" style="color: red"></span>
    </li>
    <li><input name="" type="button" class="loginbtn" value="登录"  onclick="subLogin()"  />

    </li>
    </ul>
    
    
    </div>
    
    </div>
    
    
    
    <div class="loginbm">版权所有  2013  <a href="http://www.uimaker.com">uimaker.com</a>  仅供学习交流，勿用于任何商业用途</div>




</body>

</html>

<script>
    // 登录(支持管理员及公司其他业务人员)
    function subLogin() {
        // 获取登录账号
        let loginAccount = document.getElementById("loginAccount").value;
        let loginPassword = document.getElementById("loginPassword").value;
        // 判断登录和登录密码是否为空
        if (loginAccount == "" || loginPassword == "") {
            // alert("账号或密码不能为空");
          //  document.getElementById("msg").innerText = "账号或密码不能为空";
            return;
        }
        // 使用ajax发送请求，将登录的数据提交到后台
        $.ajax({
            url: "manager/login",
            type: "get",
            data: {
                "account": loginAccount,
                "password": loginPassword

            },
            dataType: "json",
            contentType: "application/json",
            success: function (result) {
                console.log(result)
                if (result.state === true) {


                    setHeaders(result.token)
                    window.location.href = "main.html"

                } else {
                    document.getElementById("tip").innerText = "账号或密码不正确";
                    return;
                }
            }
        })
    }
    function setHeaders(token) {
        $.ajaxSetup({
            headers: {
                'token': '' + token,
                'Content-Type': 'application/json'
            }
        });
    }

</script>